package com.ipoint.intr.smartCatalog.controller.template;

import javax.persistence.EntityManager;

import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Out;
import org.jboss.seam.annotations.Scope;

import com.ipoint.intr.smartCatalog.model.template.Attribute;
import com.ipoint.intr.smartCatalog.model.template.Template;

@Name("editTemplateController")
@Scope(ScopeType.STATELESS)
public class EditTemplateController {

	@In(required = false, value = Template.EDIT_TEMPLATE_NAME)
	@Out(required = false, value = Template.EDIT_TEMPLATE_NAME)
	private Template template;
	
	@In(required = false, value = Attribute.EDIT_ATTRIBUTE_NAME)
	@Out(required = false, value = Attribute.EDIT_ATTRIBUTE_NAME)
	private Attribute attribute;

	@In
	private EntityManager entityManager;

	public void create(Template template) {
		entityManager.persist(template);
	}

	public void create(Attribute editAttribute) {
		template.getAttributeList().add(attribute);
	}	
}
